import React, { useRef } from 'react';
import './index.css'

const Index = (props) => {

    const { show, addFrom } = props

    const InputRef = useRef()

    const addFromValue = () => {
        const value = InputRef.current.value.trim()

        if (value.length == 0) return;

        addFrom(value)

        InputRef.current.value = ''
    }

    return (
        show && <div className='input-from'>
            <input ref={InputRef} type='text' placeholder='请输入代办事件'></input>
            <button onClick={addFromValue}>添加</button>
        </div>
    );
};

export default Index;